package com.xiegang.orderservice.controller;


import com.xiegang.internalcommon.dto.ResponseResult;
import com.xiegang.internalcommon.request.OrderRequest;
import com.xiegang.orderservice.service.OrderInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xieGang
 * @since 2023-04-07
 */
@RestController
@RequestMapping("/order")
@Slf4j
public class OrderInfoController {

    @Autowired
    private OrderInfoService orderInfoService;

    @PostMapping("/add")
    public ResponseResult add(@RequestBody OrderRequest orderRequest, HttpServletRequest httpServletRequest){

//        String deviceCode = httpServletRequest.getHeader(HearParamContants.DEVICE_CODE);
//        orderRequest.setDeviceCode(deviceCode);

        log.info(orderRequest.getAddress());
        return orderInfoService.add(orderRequest);
    }

    @PostMapping("/to-pick-up-passenger")
    public ResponseResult toPickUpPassenger(@RequestBody OrderRequest orderRequest){

        return orderInfoService.toPickUpPassenger(orderRequest);
    }

    @PostMapping("/arrivedDeparture")
    public ResponseResult arrivedDeparture(@RequestBody OrderRequest orderRequest){

        return orderInfoService.arrivedDeparture(orderRequest);
    }
}
